﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_Admin_DSJCJ.Common;
using System.Data;
using System.Text;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
    /// <summary>
    /// 银行余额汇总表
    /// </summary>
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class FwmmyhController : AdminBaseController
    {
        /// <summary>
        /// 
        /// </summary>
        private BLL.Fwmmyhsr fwmmyhsrBLL = new BLL.Fwmmyhsr();
        decimal Sum19 = 0;
        decimal Sum20 = 0;
        decimal Sum21 = 0;
        decimal Sum22 = 0;
        decimal Sum23 = 0;
        decimal Sum24 = 0;
        decimal Sum25 = 0;
        decimal Sum26 = 0;
        decimal Sum27 = 0;
        decimal Sum28 = 0;
        decimal Sum29 = 0;
        decimal Sum30 = 0;
        //
        // GET: /Admin/Fwmmyh/
        /// <summary>
        /// 银行余额汇总表主页
        /// </summary>
        /// <returns>视图</returns>
        [AuthorityActionFilter("m_Fwmmyh", Order = 1)]
        [LogPageActionFilter(" 银行余额汇总表", Order = 2)]      
        public ActionResult Index()
        {
            Load();
            return View();
        }
        /// <summary>
        /// 加载Table
        /// </summary>
        private void Load() 
        {
            string yyyy = Fetch.Post("tbyyyy").Trim() == "" ? DateTime.Now.Year + "" : Fetch.Post("tbyyyy").Trim();
            string mm = Fetch.Post("tbmm".Trim()) == "" ? DateTime.Now.Month + "" : Fetch.Post("tbmm").Trim();

            ViewData["yyyy"] = yyyy;
            ViewData["mm"] = mm;
            DataSet data = fwmmyhsrBLL.GetNextDate(yyyy, mm);

            //第一张表
            string stratDate = yyyy + "-" + mm + "-05";
            string endDate = yyyy + "-" + mm + "-20";
            string strFirstDetailTable = GetStrDetailTable(stratDate, endDate);
            ViewData["strFirstDetailTable"] = strFirstDetailTable;
            string strFirstTable = GetStrTable(stratDate, endDate);
            ViewData["strFirstTable"] = strFirstTable;

            //第二张表        
            ViewData["rq2"] = data.Tables[0].Rows[0]["day"].ToString();
            string rq2 = data.Tables[0].Rows[0]["day"].ToString().Substring(0, 4) + "-"
                            + data.Tables[0].Rows[0]["day"].ToString().Substring(4, 2)
                            + "-" + data.Tables[0].Rows[0]["day"].ToString().Substring(6, 2);
            stratDate = yyyy + "-" + mm + "-20";
            endDate = rq2;
            string strSecondDetailTable = GetStrDetailTable(stratDate, endDate);
            ViewData["strSecondDetailTable"] = strSecondDetailTable;
            string strSecondTable = GetStrTable(stratDate, endDate);
            ViewData["strSecondTable"] = strSecondTable;

            //第三张表
            data = fwmmyhsrBLL.GetPreDate(yyyy, mm);
            rq2 = data.Tables[0].Rows[0]["day"].ToString().Substring(0, 4) + "-"
                            + data.Tables[0].Rows[0]["day"].ToString().Substring(4, 2)
                            + "-" + data.Tables[0].Rows[0]["day"].ToString().Substring(6, 2);
            stratDate = rq2;
            endDate = yyyy + "-" + mm + "-20";
            string strThreeDetailTable = GetStrDetailTable(stratDate, endDate);
            ViewData["strThreeDetailTable"] = strThreeDetailTable;
            string strThreeTable = GetStrTable(stratDate, endDate);
            ViewData["strThreeTable"] = strThreeTable;
           
        }

        /// <summary>
        /// 银行汇率总表的Table
        /// </summary>
        /// <param name="stratDate">月开始时间</param>
        /// <param name="endDate">月结束时间</param>
        /// <returns>表格</returns>
        private string GetStrTable(string stratDate, string endDate) 
        {
            decimal BPNumSum = 0;
            decimal CurrReveSum = 0;
            decimal CurrExpendSum = 0;
            decimal CurrRemainingSum = 0;

            StringBuilder strTable = new StringBuilder();
            DataSet ds = fwmmyhsrBLL.GetBankPayBalance(stratDate, endDate);
            strTable.Append("<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">");
            strTable.Append("<tr><td align=\"center\" colspan=\"5\" height=\"30\">银行收支情况</td>");
            strTable.Append("<td align=\"center\" colspan=\"6\">财政补贴汇总</td></tr>");
            strTable.Append("<tr>");
            strTable.Append("<td rowspan=\"2\" align=\"center\">银行</td>");
            strTable.Append("<td rowspan=\"2\" align=\"center\">期初数</td>");
            strTable.Append("<td rowspan=\"2\" align=\"center\">本期收入</td>");
            strTable.Append("<td rowspan=\"2\" align=\"center\">本期支出</td>");
            strTable.Append("<td rowspan=\"2\" align=\"center\">本期余额</td>");
            strTable.Append("<td height=\"30\" colspan=\"3\" align=\"center\">户数</td>");
            strTable.Append("<td height=\"30\" colspan=\"3\" align=\"center\">金额</td>");
            strTable.Append("</tr>");
            strTable.Append("<tr>");
            strTable.Append("<td height=\"30\" align=\"center\">本期</td>");
            strTable.Append("<td height=\"30\" align=\"center\">本年累计</td>");
            strTable.Append("<td height=\"30\" align=\"center\">历年累计</td>");
            strTable.Append("<td height=\"30\" align=\"center\">本期</td>");
            strTable.Append("<td height=\"30\" align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("</tr>");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["银行"].ToString() == "农行")
                {
                    strTable.Append("<tr>");
                    strTable.Append("<td height=\"30\" align=\"center\">" + ds.Tables[0].Rows[i]["银行"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["期初数"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期收入"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期支出"].ToString() + "</td>");
                    decimal RemainingSum = decimal.Parse(ds.Tables[0].Rows[i]["期初数"].ToString()) + decimal.Parse(ds.Tables[0].Rows[i]["本期收入"].ToString()) - decimal.Parse(ds.Tables[0].Rows[i]["本期支出"].ToString());
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + RemainingSum + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum19 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum20 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum21 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum22 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum23 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum24 + "</td>");
                    strTable.Append("</tr>");
                    BPNumSum += decimal.Parse(ds.Tables[0].Rows[i]["期初数"].ToString());
                    CurrReveSum += decimal.Parse(ds.Tables[0].Rows[i]["本期收入"].ToString());
                    CurrExpendSum += decimal.Parse(ds.Tables[0].Rows[i]["本期支出"].ToString());
                    CurrRemainingSum += RemainingSum;
                }
                else if (ds.Tables[0].Rows[i]["银行"].ToString() == "鄞州银行") 
                {
                    strTable.Append("<tr>");
                    strTable.Append("<td height=\"30\" align=\"center\">" + ds.Tables[0].Rows[i]["银行"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["期初数"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期收入"].ToString() + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期支出"].ToString() + "</td>");
                    decimal RemainingSum = decimal.Parse(ds.Tables[0].Rows[i]["期初数"].ToString()) + decimal.Parse(ds.Tables[0].Rows[i]["本期收入"].ToString()) - decimal.Parse(ds.Tables[0].Rows[i]["本期支出"].ToString());
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + RemainingSum + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum25 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum26 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum27 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum28 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum29 + "</td>");
                    strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum30 + "</td>");
                    strTable.Append("</tr>");
                    BPNumSum += decimal.Parse(ds.Tables[0].Rows[i]["期初数"].ToString());
                    CurrReveSum += decimal.Parse(ds.Tables[0].Rows[i]["本期收入"].ToString());
                    CurrExpendSum += decimal.Parse(ds.Tables[0].Rows[i]["本期支出"].ToString());
                    CurrRemainingSum += RemainingSum;
                }
            }
            decimal SSum1 = Sum19 + Sum25;
            decimal SSum2 = Sum20 + Sum26;
            decimal SSum3 = Sum21 + Sum27;
            decimal SSum4 = Sum22 + Sum28;
            decimal SSum5 = Sum23 + Sum29;
            decimal SSum6 = Sum24 + Sum30;
            strTable.Append("<tr>");
            strTable.Append("<td height=\"30\" align=\"center\">合计</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + BPNumSum + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + CurrReveSum + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + CurrExpendSum + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + CurrRemainingSum + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum1 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum2 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum3 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum4 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum5 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + SSum6 + "</td>");
            strTable.Append("</tr>");
            strTable.Append("</table>");

            return strTable.ToString();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        //private string GetStrNullTable()
        //{
        //    StringBuilder strTable = new StringBuilder();
        //    strTable.Append("<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">");
        //    strTable.Append("<tr><td align=\"center\" colspan=\"5\" height=\"30\">银行收支情况</td>");
        //    strTable.Append("<td align=\"center\" colspan=\"6\">财政补贴汇总</td></tr>");
        //    strTable.Append("<tr>");
        //    strTable.Append("<td rowspan=\"2\" align=\"center\">银行</td>");
        //    strTable.Append("<td rowspan=\"2\" align=\"center\">期初数</td>");
        //    strTable.Append("<td rowspan=\"2\" align=\"center\">本期收入</td>");
        //    strTable.Append("<td rowspan=\"2\" align=\"center\">本期支出</td>");
        //    strTable.Append("<td rowspan=\"2\" align=\"center\">本期余额</td>");
        //    strTable.Append("<td height=\"30\" colspan=\"3\" align=\"center\">户数</td>");
        //    strTable.Append("<td height=\"30\" colspan=\"3\" align=\"center\">金额</td>");
        //    strTable.Append("</tr>");
        //    strTable.Append("<tr>");
        //    strTable.Append("<td height=\"30\" align=\"center\">本期</td>");
        //    strTable.Append("<td height=\"30\" align=\"center\">本年累计</td>");
        //    strTable.Append("<td height=\"30\" align=\"center\">历年累计</td>");
        //    strTable.Append("<td height=\"30\" align=\"center\">本期</td>");
        //    strTable.Append("<td height=\"30\" align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("</tr>");

        //    strTable.Append("<tr>");
        //    strTable.Append("<td height=\"30\" align=\"center\">农行</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("</tr>");

        //    strTable.Append("<tr>");
        //    strTable.Append("<td height=\"30\" align=\"center\">鄞州银行</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("</tr>");

        //    strTable.Append("<tr>");
        //    strTable.Append("<td height=\"30\" align=\"center\">合计</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("</tr>");
        //    strTable.Append("</table>");

        //    return strTable.ToString();
        //}
        /// <summary>
        /// 获得下面的明细表
        /// </summary>
        /// <param name="stratDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns></returns>
        private string GetStrDetailTable(string stratDate, string endDate) 
        {
            StringBuilder strTable = new StringBuilder();
            decimal Sum1 = 0;
            decimal Sum2 = 0;
            decimal Sum3 = 0;
            decimal Sum4 = 0;
            decimal Sum5 = 0;
            decimal Sum6 = 0;
            decimal Sum7 = 0;
            decimal Sum8 = 0;
            decimal Sum9 = 0;
            decimal Sum10 = 0;
            decimal Sum11 = 0;
            decimal Sum12 = 0;
            decimal Sum13 = 0;
            decimal Sum14 = 0;
            decimal Sum15 = 0;
            decimal Sum16 = 0;
            decimal Sum17 = 0;
            decimal Sum18 = 0;

            Sum19 = 0;
            Sum20 = 0;
            Sum21 = 0;
            Sum22 = 0;
            Sum23 = 0;
            Sum24 = 0;
            Sum25 = 0;
            Sum26 = 0;
            Sum27 = 0;
            Sum28 = 0;
            Sum29 = 0;
            Sum30 = 0;

            DataSet ds = fwmmyhsrBLL.GetFiscalSubsidies(stratDate, endDate);
            strTable.Append("<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">");
            strTable.Append("<tr><td colspan=\"6\" align=\"center\" height=\"30\">契税</td>");
            strTable.Append("<td colspan=\"6\" align=\"center\" height=\"30\">个人所得税</td>");
            strTable.Append("<td colspan=\"6\" align=\"center\" height=\"30\">自住型、改善型购房</td></tr>");
            strTable.Append("<tr><td colspan=\"3\" align=\"center\" height=\"30\">户数</td>");
            strTable.Append("<td colspan=\"3\" align=\"center\">金额</td>");
            strTable.Append("<td colspan=\"3\" align=\"center\">户数</td>");
            strTable.Append("<td colspan=\"3\" align=\"center\">金额</td>");
            strTable.Append("<td colspan=\"3\" align=\"center\">户数</td>");
            strTable.Append("<td colspan=\"3\" align=\"center\">金额</td></tr>");
            strTable.Append("<tr><td align=\"center\" height=\"30\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("<td align=\"center\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("<td align=\"center\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("<td align=\"center\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("<td align=\"center\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td>");
            strTable.Append("<td align=\"center\">本期</td>");
            strTable.Append("<td align=\"center\">本年累计</td>");
            strTable.Append("<td align=\"center\">历年累计</td></tr>");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "农行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "契税")
                    {
                        strTable.Append("<tr><td align=\"center\" height=\"30\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td>");
                        Sum1 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum2 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum3 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum4 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum5 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum6 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum19 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum20 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum21 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum22 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum23 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum24 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }
                }
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "农行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "个人所得税")
                    {
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td>");
                        Sum7 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum8 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum9 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum10 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum11 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum12 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum19 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum20 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum21 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum22 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum23 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum24 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }            
                }
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "农行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "自住改善型")
                    {
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td>");
                        Sum13 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum14 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum15 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum16 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum17 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum18 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum19 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum20 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum21 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum22 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum23 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum24 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }
                }
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "鄞州银行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "契税")
                    {
                        strTable.Append("<tr><td align=\"center\" height=\"30\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\" >" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td>");
                        Sum1 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum2 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum3 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum4 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum5 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum6 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum25 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum26 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum27 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum28 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum29 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum30 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }
                }
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "鄞州银行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "个人所得税")
                    {
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td>");
                        Sum7 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum8 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum9 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum10 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum11 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum12 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum25 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum26 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum27 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum28 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum29 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum30 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }
                }
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["开户银行"].ToString() == "鄞州银行")
                {
                    if (ds.Tables[0].Rows[i]["税种"].ToString() == "自住改善型")
                    {
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计户数"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本期金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["本年累计金额"].ToString() + "</td>");
                        strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + ds.Tables[0].Rows[i]["历年累计金额"].ToString() + "</td></tr>");
                        Sum13 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum14 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum15 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum16 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum17 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum18 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());

                        Sum25 += decimal.Parse(ds.Tables[0].Rows[i]["本期户数"].ToString());
                        Sum26 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计户数"].ToString());
                        Sum27 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计户数"].ToString());
                        Sum28 += decimal.Parse(ds.Tables[0].Rows[i]["本期金额"].ToString());
                        Sum29 += decimal.Parse(ds.Tables[0].Rows[i]["本年累计金额"].ToString());
                        Sum30 += decimal.Parse(ds.Tables[0].Rows[i]["历年累计金额"].ToString());
                    }
                }
            }

            strTable.Append("<tr><td align=\"center\" height=\"30\" style=\"font-size:14px;\">" + Sum1 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum2 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum3 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum4 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum5 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum6 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum7 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum8 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum9 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum10 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum11 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum12 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum13 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum14 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum15 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum16 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum17 + "</td>");
            strTable.Append("<td align=\"center\" style=\"font-size:14px;\">" + Sum18 + "</td></tr>");
            strTable.Append("</table>");

            return strTable.ToString();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        //private string GetStrNullDetailTable()
        //{
        //    StringBuilder strTable = new StringBuilder();
        //    strTable.Append("<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">");
        //    strTable.Append("<tr><td colspan=\"6\" align=\"center\" height=\"30\">契税</td>");
        //    strTable.Append("<td colspan=\"6\" align=\"center\" height=\"30\">个人所得税</td>");
        //    strTable.Append("<td colspan=\"6\" align=\"center\" height=\"30\">自住型、改善型购房</td></tr>");
        //    strTable.Append("<tr><td colspan=\"3\" align=\"center\" height=\"30\">户数</td>");
        //    strTable.Append("<td colspan=\"3\" align=\"center\">金额</td>");
        //    strTable.Append("<td colspan=\"3\" align=\"center\">户数</td>");
        //    strTable.Append("<td colspan=\"3\" align=\"center\">金额</td>");
        //    strTable.Append("<td colspan=\"3\" align=\"center\">户数</td>");
        //    strTable.Append("<td colspan=\"3\" align=\"center\">金额</td></tr>");
        //    strTable.Append("<tr><td align=\"center\" height=\"30\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("<td align=\"center\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("<td align=\"center\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("<td align=\"center\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("<td align=\"center\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td>");
        //    strTable.Append("<td align=\"center\">本期</td>");
        //    strTable.Append("<td align=\"center\">本年累计</td>");
        //    strTable.Append("<td align=\"center\">历年累计</td></tr>");

        //    strTable.Append("<tr><td align=\"center\" height=\"30\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");

        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");

        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td></tr>");

        //    strTable.Append("<tr><td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");


        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");

        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td></tr>");


        //    strTable.Append("<tr><td align=\"center\" height=\"30\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td>");
        //    strTable.Append("<td align=\"center\">0</td></tr>");
        //    strTable.Append("</table>");

        //    return strTable.ToString();
        //}
        /// <summary>
        /// 打印页面
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult IndexPrint()
        {
            Load();        
            return View();
        }

        /// <summary>
        /// 查询页面
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult SaveFwmmyh()
        {
            Load();
            return View("Index");
        }
        /// <summary>
        /// 打印查询页面
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult SavePrintFwmmyh()
        {
            Load();
            return View("IndexPrint");
        }

       
    }

}
